<template>
  <!-- 底部部分 -->
  <footer class="footer">
    <span class="todo-count"
      ><strong>{{ sum }}</strong
      >剩余</span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: listType === 'all' }"
          @click="changeType('all')"
          href="#/"
          >全部</a
        >
      </li>
      <li>
        <a
          :class="{ selected: listType === 'active' }"
          @click="changeType('active')"
          href="#/active"
          >进行中</a
        >
      </li>
      <li>
        <a
          :class="{ selected: listType === 'completed' }"
          @click="changeType('completed')"
          href="#/completed"
          >已完成</a
        >
      </li>
    </ul>
    <button class="clear-completed" v-if="showClearBtn" @click="delAll">
      清除已完成
    </button>
  </footer>
</template>
 
<script>
export default {
  name: 'TodoListFooter',
  props: {
    sum: {
      type: Number,
      required: true
    },
    showClearBtn: {
      type: Boolean,
      required: true
    },
    listType: {
      type: String,
      required: true
    }
  },
  methods: {
    //删除所有已完成的事件
    delAll() {
      this.$emit('delAll')
    },

    //修改状态
    changeType(value) {
      this.$emit('changeType', value)
    }
  }
}
</script>

<style scoped>
</style>